<template>
  <div class="page" @click="hideDiv">
    <!-- 标题 -->
    <div class="header">
      {{ headTitle }}
      <span style="float: right; font-size: 14px; font-weight: 400; color: #666"
        ><span style="color: red">*</span> 为必填项</span
      >
    </div>
    <div class="content">
      <div v-for="(item, i) in titleArr" :key="i">
        <!-- <div class="title" style="display: flex">
            <div class="block"></div>
            <span class="collapse-title">{{ item }}</span>
          </div> -->
        <TitleName
          :title="item"
          icon="i-carbon-bookmark-filled"
          style="margin: 20px 0 5px -2px"
        ></TitleName>
        <el-form label-width="100px" class="demo-ruleForm" label-position="top">
          <el-row :gutter="80" class="row">
            <template v-for="(row, index) in fieldArr[i]" :key="index">
              <el-col
                class="col"
                :span="row.span"
                v-if="!exceptTime.includes(row.id) && row.label != '编制情况'"
              >
                <div class="item item-label">
                  {{ row.label }}
                  <span v-if="row.required" style="color: red"> *</span>
                </div>
                <template v-if="row.type === 'treeselect'">
                  <el-tree-select
                    style="width: 100%"
                    v-model="valueObject[row.id]"
                    :data="customerOption[row.id]"
                    :props="
                      row.options?.props
                        ? row.options?.props
                        : {
                            value: 'id',
                            label: 'label',
                            children: 'children'
                          }
                    "
                    :placeholder="row.placeholder"
                    :value-key="
                      row.options?.valueKey ? row.options?.valueKey : 'id'
                    "
                    v-bind="row.options"
                    filterable
                  />
                </template>
                <template
                  v-else-if="
                    row.type === 'select' &&
                    ['classes', 'jobType', 'jobTitle'].includes(row.id)
                  "
                >
                  <el-select
                    @click="hideDiv"
                    style="width: 100%"
                    :filterable="row.filterable"
                    :multiple="row.multiple"
                    @change="changeEmployeeStatus($event, row.id)"
                    class="item item-value"
                    :placeholder="row.placeholder"
                    v-model="valueObject[row.id]"
                    v-hasPermi="['system:employee:authority']"
                    clearable
                  >
                    <el-option
                      v-for="(item, index) in customerOption[row.id]"
                      :value="item.value"
                      :label="item.label"
                      :key="'op' + index"
                    >
                      {{ item.label }}
                    </el-option>
                  </el-select>
                </template>
                <template
                  v-else-if="
                    row.type === 'select' &&
                    !['classes', 'jobType', 'jobTitle'].includes(row.id)
                  "
                >
                  <el-select
                    @click="hideDiv"
                    style="width: 100%"
                    :filterable="row.filterable"
                    :multiple="row.multiple"
                    @change="changeEmployeeStatus($event, row.id)"
                    class="item item-value"
                    :placeholder="row.placeholder"
                    v-model="valueObject[row.id]"
                    clearable
                  >
                    <el-option
                      v-for="(item, index) in customerOption[row.id]"
                      :value="item.value"
                      :label="item.label"
                      :key="'op' + index"
                    >
                      {{ item.label }}
                    </el-option>
                  </el-select>
                </template>

                <template v-else-if="row.type === 'input'">
                  <div v-if="row.id == 'leaveDate' && isLeaveDate">
                    <el-input
                      class="item item-value"
                      v-model="valueObject[row.id]"
                      :placeholder="row.placeholder"
                    />
                  </div>
                </template>

                <template v-else-if="row.type === 'radio' && row.id == 'vpn'">
                  <div v-hasPermi="['system:employee:authority']">
                    <el-radio-group
                      class="item item-value"
                      v-model="valueObject[row.id]"
                      :placeholder="row.placeholder"
                    >
                      <el-radio value="0" label="0">否</el-radio>
                      <el-radio value="1" label="1">是</el-radio>
                    </el-radio-group>
                  </div>
                </template>
                <template
                  v-else-if="row.type === 'radio' && row.id == 'isTrainee'"
                >
                  <div>
                    <el-radio-group
                      class="item item-value"
                      v-model="valueObject[row.id]"
                      :placeholder="row.placeholder"
                    >
                      <el-radio value="0" label="0">否</el-radio>
                      <el-radio value="1" label="1">是</el-radio>
                    </el-radio-group>
                  </div>
                </template>
                <template v-else-if="row.type === 'textarea'">
                  <el-input
                    type="textarea"
                    :placeholder="row.placeholder"
                    v-model="valueObject[row.id]"
                    maxlength="100"
                    show-word-limit
                  >
                  </el-input>
                </template>
                <template v-else-if="!row.jgdiv">
                  <el-input
                    class="item item-value"
                    v-model="valueObject[row.id]"
                    :placeholder="row.placeholder"
                  />
                </template>
                <el-input
                  v-else
                  class="item item-value"
                  v-model="valueObject[row.id]"
                  :placeholder="row.placeholder"
                  @focus="showJgdiv = true"
                  @click="settingEvent($event)"
                />
                <div
                  v-if="row.jgdiv"
                  class="jgdiv"
                  :style="showJgdiv ? 'display:block' : 'display:none'"
                >
                  <el-tabs
                    v-model="activeNameT"
                    @tab-change="handleClick"
                    @click="settingEvent($event)"
                  >
                    <el-tab-pane
                      class="tab-pane"
                      v-for="item in tabRrr"
                      :label="item"
                      :name="item"
                    >
                      <div
                        class="city-item-div"
                        @click.stop="handleItemClick(index, cityItem.city)"
                        v-for="(cityItem, index) in cityResponse.data"
                        :key="index"
                        :class="curIndex == index ? 'active' : ''"
                      >
                        {{ cityItem.city }}
                      </div>
                    </el-tab-pane>
                  </el-tabs>
                </div>
              </el-col>
              <el-col
                class="col"
                :span="row.span"
                v-else-if="
                  exceptTime.includes(row.id) &&
                  isLeaveDate &&
                  getLabel(row.id).value == valueObject.employeeStatus
                "
              >
                <div class="item item-label">
                  {{ getLabel(row.id).label }}
                  <span v-if="row.required" style="color: red"> *</span>
                </div>

                <template v-if="row.type === 'input'">
                  <div>
                    <el-input
                      class="item item-value"
                      v-model="valueObject[getLabel(row.id).id]"
                      :placeholder="row.placeholder"
                    />
                  </div>
                </template>
              </el-col>
              <el-col
                class="col"
                :span="row.span"
                v-if="
                  !exceptTime.includes(row.id) &&
                  row.label == '编制情况' &&
                  isEstablishment == '1'
                "
              >
                <div class="item item-label">
                  {{ row.label }}
                  <span v-if="row.required" style="color: red"> *</span>
                </div>

                <template v-if="row.type === 'select'">
                  <el-select
                    @click="hideDiv"
                    style="width: 100%"
                    :filterable="row.filterable"
                    :multiple="row.multiple"
                    @change="changeEmployeeStatus($event, row.id)"
                    class="item item-value"
                    :placeholder="row.placeholder"
                    v-model="valueObject[row.id]"
                  >
                    <el-option
                      v-for="(item, index) in customerOption[row.id]"
                      :value="item.value"
                      :label="item.label"
                      :key="'op' + index"
                    >
                      {{ item.label }}
                    </el-option>
                  </el-select>
                </template>
              </el-col>
            </template>
          </el-row>
        </el-form>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClickNext">
        <el-tab-pane label="学习经历" name="1">
          <mytable
            :tableName="'学习经历'"
            :tableField="xxjlTableField"
            :tableData="employeeStudyList"
            :tableFlag="tableFlag"
            @handleAdd="handleAdd('学习经历')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
            @handleLink="handleLink"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="工作经历" name="2">
          <mytable
            :tableName="'工作经历'"
            :tableField="gzjlTableField"
            :tableData="employeeWorkList"
            :tableFlag="tableFlag"
            @handleAdd="handleAdd('工作经历')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
            @handleLink="handleLink"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="家庭关系" name="3">
          <mytable
            :tableName="'家庭关系'"
            :tableField="jtgxTableField"
            :tableData="employeeFamilyList"
            :tableFlag="tableFlag"
            @handleAdd="handleAdd('家庭关系')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="奖惩信息" name="4">
          <mytable
            :tableName="'奖惩信息'"
            :tableField="jcxxTableField"
            :tableData="employeeRewardList"
            :tableFlag="tableFlag"
            @handleAdd="handleAdd('奖惩信息')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="合同信息" name="5">
          <mytable
            :tableName="'合同信息'"
            :tableField="htxxTableField"
            :tableData="employeeContractList"
            :tableFlag="tableFlag"
            :contractObj="contractObj"
            @handleAdd="handleAdd('合同信息')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
            @handleLink="handleLink"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="取得证书" name="6">
          <mytable
            :tableName="'取得证书'"
            :tableField="qdzsTableField"
            :tableData="employeeCertificateList"
            :tableFlag="tableFlag"
            @handleAdd="handleAdd('取得证书')"
            @handleSave="handleSave"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
            @handleLink="handleLink"
          >
          </mytable>
        </el-tab-pane>
        <!--                <el-tab-pane label="培训情况(暂略）" name="7">-->
        <!--                    <mytable :tableField="pxqkTableField"></mytable>-->
        <!--                </el-tab-pane>-->
        <el-tab-pane label="附件资料" name="8">
          <mytable
            :tableName="'附件资料'"
            :tableField="wdzlTableField"
            :tableData="employeeDocumentList"
            @handleRemove="handleRemove"
            @handleDel="handleDel"
          >
          </mytable>
        </el-tab-pane>
        <el-tab-pane label="社保信息" name="9">
          <div class="title" style="display: flex">
            <div class="block"></div>
            <span class="collapse-title">公司缴纳基数及比例</span>
          </div>
          <el-form label-width="100px" class="demo-ruleForm">
            <el-row
              :gutter="80"
              class="row"
              v-for="(row, index) in fieldArr[3]"
              :key="'row' + index"
            >
              <template v-for="(col, index) in row" :key="index">
                <el-col
                  class="col"
                  :span="col.col ? col.col : row.length == 1 ? 24 : 8"
                >
                  <div class="item item-label">
                    {{ col.label
                    }}<span v-if="col.required" style="color: red"> *</span>
                  </div>
                  <div
                    style="display: flex; align-items: center"
                    v-if="col.type != 'date'"
                  >
                    <el-input
                      style="width: 100%"
                      class="item item-value"
                      v-model="valueObject[col.id]"
                      :placeholder="col.placeholder"
                    />
                    <el-tooltip :content="col.tipContent" placement="top">
                      <el-icon
                        style="color: #999; margin-left: 10px"
                        v-show="col.tip"
                      >
                        <InfoFilled />
                      </el-icon>
                    </el-tooltip>
                  </div>
                  <div v-else-if="col.type === 'date'">
                    <el-date-picker
                      style="width: 100%"
                      class="item item-value"
                      v-model="valueObject[col.id]"
                      value-format="YYYY-MM-DD"
                      type="date"
                      placeholder="选择日期时间"
                    />
                  </div>
                </el-col>
              </template>
            </el-row>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </div>

    <!-- 底部按钮 -->
    <div class="footer">
      <el-button
        v-if="route.currentRoute.value.query.flag == 'add'"
        type="primary"
        @click.stop="handleSubmit"
        >暂存</el-button
      >
      <el-button type="primary" @click.stop="submitForm">提交</el-button>
      <el-button @click.stop="reset">取消</el-button>
    </div>
  </div>
</template>
<script setup name="AddOrUpdateYgda">
import { validatePhoneTwo } from '@/utils/validate'
import mytable from './table'
import {
  updateEmployee,
  addEmployee,
  listJob,
  getInfo,
  studyList,
  addStudy,
  updateStudy,
  delStudy,
  workList,
  addWork,
  updateWork,
  delWork,
  familyList,
  addFamily,
  updateFamily,
  delFamily,
  rewardList,
  addReward,
  updateReward,
  delReward,
  contractList,
  addContract,
  updateContract,
  delContract,
  certificateList,
  addCertificate,
  updateCertificate,
  delCertificate,
  documentList,
  addDocument,
  updateDocument,
  delDocument,
  cityList,
  getEmployeeFiles
} from '@/api/rsgl/ygda'
import useTagsViewStore from '../../../store/modules/tagsView'
import { treeselect } from '@/api/rsgl/zzjg'

import {
  getCurrentInstance,
  onMounted,
  reactive,
  toRaw,
  toRefs,
  watch
} from 'vue'

import { useRouter } from 'vue-router'
// import { ElSelect } from 'element-plus'
// import { func } from 'vue-types'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const router = useRouter()
const route = useRouter()
const props = defineProps({
  employeeObj: {
    type: Object
  }
})

const {
  rsgl_ygda_position,
  rsgl_ygda_entrymethod,
  rsgl_ygda_registered,
  rsgl_ygda_highest_degree,
  rsgl_ygda_establishment,
  rsgl_ygda_contract,
  rsgl_ygda_employee_status,
  order_business_type,
  rsgl_classes,
  rgsl_job_type,
  rgsl_job_title
} = proxy.useDict(
  'rsgl_ygda_position',
  'rsgl_ygda_entrymethod',
  'rsgl_ygda_registered',
  'rsgl_ygda_highest_degree',
  'rsgl_ygda_establishment',
  'rsgl_ygda_contract',
  'rsgl_ygda_employee_status',
  'order_business_type',
  'rsgl_classes',
  'rgsl_job_type',
  'rgsl_job_title'
)
const isEstablishment = ref('') //编制情况
const isLeaveDate = ref(false)
const data = reactive({
  //合同期限
  contractObj: [],
  saveArr: [0, 0, 0, 0, 0, 0, 0],
  showJgdiv: false,
  curIndex: 0,
  tabRrr: ['热门', 'ABC', 'DEF', 'GHJ', 'KLM', 'NPQ', 'RST', 'WXYZ'],
  activeNameT: '热门',
  cityResponse: [],

  // 学习经历 表格字段
  xxjlTableField: [
    { label: '时间起', value: 'startDate', type: 'input', width: '160px' },
    { label: '时间止', value: 'endDate', type: 'input', width: '160px' },
    { label: '毕业院校', value: 'school', type: 'input', width: '160px' },
    { label: '专业', value: 'profession', type: 'input', width: '160px' },
    {
      label: '证书编号',
      value: 'certificateNo',
      type: 'input',
      width: '160px'
    },
    { label: '证书附件', value: 'fileName', type: 'upload', width: '160px' },
    { label: '学习方式', value: 'studyMethod', type: 'input', width: '160px' },
    { label: '毕业情况', value: 'graduation', type: 'input', width: '160px' }
  ],
  // 工作经历 表格字段
  gzjlTableField: [
    { label: '时间起', value: 'startDate', type: 'input', width: '160px' },
    { label: '时间止', value: 'endDate', type: 'input', width: '160px' },
    { label: '工作单位', value: 'company', type: 'input', width: '160px' },
    { label: '工作部门', value: 'dept', type: 'input', width: '160px' },
    { label: '担任职务', value: 'position', type: 'input', width: '160px' },
    { label: '证明人', value: 'certifier', type: 'input', width: '160px' },
    { label: '联系电话', value: 'tel', type: 'input', width: '160px' },
    { label: '离职原因', value: 'leaveReason', type: 'input', width: '160px' },
    { label: '证书附件', value: 'fileName', type: 'upload', width: '160px' }
  ],
  // 家庭关系 表格字段
  jtgxTableField: [
    { label: '序号', value: 'index', width: '160px' },
    { label: '关系', value: 'relation', type: 'input', width: '160px' },
    { label: '姓名', value: 'name', type: 'input', width: '160px' },
    { label: '出生年月', value: 'birthday', type: 'input', width: '160px' },
    { label: '政治面貌', value: 'political', type: 'input', width: '160px' },
    { label: '单位', value: 'company', type: 'input', width: '160px' },
    { label: '职务', value: 'position', type: 'input', width: '160px' },
    { label: '联系电话', value: 'tel', type: 'input', width: '160px' }
  ],
  // 奖惩信息 表格字段
  jcxxTableField: [
    { label: '序号', value: 'index', width: '110px' },
    { label: '时间', value: 'rewardDate', type: 'input', width: '160px' },
    { label: '奖惩内容', value: 'reward', type: 'input' },
    { label: '奖惩说明', value: 'rewardRemark', type: 'input' }
  ],

  // 合同信息 表格字段
  htxxTableField: [
    { label: '合同编号', value: 'contractNo', type: 'input', width: '160px' },
    { label: '签订时间', value: 'signDate', type: 'input', width: '160px' },
    {
      label: '合同期限',
      value: 'contractType',
      type: 'select',
      width: '160px'
    },
    { label: '有效期起', value: 'startDate', type: 'input', width: '160px' },
    { label: '有效期止', value: 'endDate', type: 'input', width: '160px' },
    { label: '备注', value: 'remark', type: 'input', width: '160px' },
    { label: '合同附件', value: 'fileName', type: 'upload', width: '160px' }
  ],
  // 取得证书 表格字段
  qdzsTableField: [
    { label: '序号', value: 'index', width: '110px' },
    { label: '获取时间', value: 'getDate', type: 'input', width: '160px' },
    {
      label: '证书名称',
      value: 'certificateName',
      type: 'input',
      width: '160px'
    },
    {
      label: '证书级别',
      value: 'certificateLevel',
      type: 'input',
      width: '160px'
    },
    {
      label: '取得证书途径',
      value: 'certificateAccess',
      type: 'input',
      width: '160px'
    },
    {
      label: '证书评定单位',
      value: 'certificateDept',
      type: 'input',
      width: '160px'
    },
    {
      label: '证书编号',
      value: 'certificateNo',
      type: 'input',
      width: '160px'
    },
    { label: '证书附件', value: 'fileName', type: 'upload', width: '160px' }
    // filePath
  ],
  // 培训情况 表格字段
  pxqkTableField: [
    { label: '时间起', value: 'studentCode', type: 'date' },
    { label: '时间止', value: 'studentName', type: 'date' },
    { label: '培训课程', value: 'studentAge' },
    { label: '获得证书', value: 'studentCode' },
    { label: '证书编号', value: 'studentCode' },
    { label: '备注', value: 'studentCode' }
  ],
  // 附件资料 表格字段
  wdzlTableField: [
    { label: '序号', value: 'index', width: '110px' },
    { label: '附件性质', value: 'documentNature', type: 'nature' },
    // { label: '附件名称', value: 'fileName', type: 'upload' }
    { label: '附件名称', value: 'fileName', type: 'documentName' }
  ],
  // 头部标题
  headTitle: '员工档案编辑/新增',
  // 标题数组
  titleArr: ['基础信息', '入司情况', '教育情况'],
  activeName: '1',
  // 字段数组
  fieldArr: [
    // 基础信息
    [
      {
        label: '姓       名',
        id: 'employeeName',
        required: true,
        placeholder: '请输入姓名',
        span: 8
      },
      {
        label: '性       别',
        id: 'sex',
        required: true,
        type: 'select',
        placeholder: '请选择性别',
        span: 8
      },
      {
        label: '出生年月',
        id: 'birthday',
        required: true,
        placeholder: '出生年月YYYY-MM-DD或 YYYY-MM',
        span: 8
      },

      { label: '民      族', id: 'nation', placeholder: '请输入民族', span: 8 },
      {
        label: '籍      贯',
        id: 'nativePlace',
        jgdiv: true,
        required: true,
        placeholder: '请输入籍贯',
        span: 8
      },
      {
        label: '家庭地址',
        id: 'homeAddress',
        required: true,
        placeholder: '请输入家庭地址',
        span: 8
      },

      {
        label: '户口性质',
        id: 'registeredType',
        type: 'select',
        placeholder: '请选择户口性质',
        span: 8
      },
      {
        label: '户籍所在地',
        id: 'residencePlace',
        required: true,
        placeholder: '请输入户籍所在地',
        span: 8
      },
      {
        label: '现住址',
        id: 'currentAddress',
        required: true,
        placeholder: '请输入现住址',
        span: 8
      },

      {
        label: '身份证号',
        id: 'idNumber',
        placeholder: '请输入身份证号',
        span: 8
      },
      {
        label: '婚姻状况',
        id: 'maritalStatus',
        type: 'select',
        placeholder: '请选择婚姻状况',
        span: 8
      },
      {
        label: '参加工作时间',
        id: 'workDate',
        placeholder: '参加工作时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },

      {
        label: '政治面貌',
        id: 'political',
        type: 'select',
        placeholder: '请选择政治面貌',
        span: 8
      },
      {
        label: '入党/入团时间',
        id: 'entryPartyTime',
        placeholder: '入党/入团时间YYYY-MM-DD或 YYYY-MM',
        span: 8
        //   type: 'date'
      },
      {
        label: '专业技术职称',
        id: 'technical',
        placeholder: '请输入专业技术职称',
        span: 8
      },
      {
        label: '编制情况',
        id: 'establishment',
        type: 'select',
        placeholder: '请选择编制情况',
        span: 8
      },
      {
        label: '业务版块',
        id: 'businessSector',
        multiple: 'true',
        type: 'treeselect',
        placeholder: '请选择业务版块',
        options: {
          showCheckbox: false,
          props: {
            value: 'value',
            label: 'label',
            children: 'children'
          },
          multiple: true,
          checkStrictly: true,
          clearable: true
        },
        span: 8
      },
      {
        label: '办公电话',
        id: 'officePhone',
        placeholder: '请输入办公电话',
        span: 8
      },
      {
        label: '手机号码',
        id: 'mobile',
        placeholder: '请输入手机号码',
        span: 8
      },

      // { label: '办公电话', id: 'officePhone', placeholder: '请输入手机号码' },
      { label: '个人邮箱', id: 'mail', placeholder: '请输入个人邮箱', span: 8 },
      {
        label: '微信号码',
        id: 'wechat',
        placeholder: '请输入微信号码',
        span: 8
      },
      {
        label: '邮政编码',
        id: 'postalCode',
        placeholder: '请输入邮政编码',
        span: 8
      },

      { label: 'QQ号码', id: 'qq', placeholder: '请输入QQ号码', span: 8 },
      {
        label: '兴趣爱好',
        id: 'hobbies',
        placeholder: '请输入兴趣爱好',
        span: 8
      },
      {
        label: '是否VPN',
        id: 'vpn',
        type: 'radio',
        placeholder: '请选择',
        span: 8
      },
      {
        label: '分类',
        id: 'classes',
        type: 'select',
        placeholder: '请选择分类',
        span: 8
      },
      {
        label: '职类',
        id: 'jobType',
        type: 'select',
        placeholder: '请选择职类',
        span: 8
      },
      {
        label: '职称',
        id: 'jobTitle',
        type: 'select',
        placeholder: '请选择职称',
        span: 8,
        multiple: true
      },

      { label: '特长', id: 'speciality', placeholder: '请输入特长', span: 24 },

      {
        label: '自我评价',
        id: 'selfEvaluation',
        type: 'textarea',
        placeholder: '请输入自我评价',
        span: 24
      }
    ],

    // 入司情况
    [
      {
        label: '所属单位',
        id: 'companyId',
        type: 'treeselect',
        placeholder: '请选择所属单位',
        required: true,
        span: 8
      },
      {
        label: '所属部门',
        id: 'deptId',
        type: 'treeselect',
        placeholder: '请选择所属部门',
        required: true,
        span: 8
      },
      {
        label: '职务',
        id: 'position',
        type: 'select',
        required: true,
        placeholder: '请选择职务',
        span: 8
      },

      {
        label: '员工工号',
        id: 'employeeNo',
        required: true,
        placeholder: '请输入员工工号',
        span: 8
      },
      {
        label: '员工编号',
        id: 'employeeNumber',
        required: false,
        placeholder: '请输入员工编号',
        span: 8
      },
      {
        label: '岗       位',
        id: 'job',
        type: 'select',
        filterable: true,
        required: true,
        placeholder: '请选择岗位',
        span: 8
      },

      {
        label: '岗位类别',
        id: 'jobCategory',
        required: false,
        placeholder: '请输入岗位类别',
        span: 8
      },
      {
        label: '入职方式',
        id: 'entryMethod',
        type: 'select',
        required: true,
        placeholder: '请选择入职方式',
        span: 8
      },
      {
        label: '入司时间',
        id: 'entryCompanyTime',
        placeholder: '入司时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },

      {
        label: '转正时间',
        id: 'turnTime',
        placeholder: '转正时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '员工状态',
        id: 'employeeStatus',
        type: 'select',
        required: true,
        placeholder: '请选择员工状态',
        span: 8
      },
      {
        label: '离职时间',
        id: 'leaveDate',
        type: 'input',
        placeholder: '离职时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '预计转正时间',
        id: 'turnTimePlan',
        type: 'input',
        placeholder: '预计转正时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '退休时间',
        id: 'retirementTime',
        type: 'input',
        placeholder: '退休时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '实习开始时间',
        id: 'internshipBeginTime',
        type: 'input',
        placeholder: '实习开始时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '实习结束时间',
        id: 'internshipEndTime',
        type: 'input',
        placeholder: '实习结束时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      },
      {
        label: '职业发展设想',
        id: 'development',
        type: 'textarea',
        placeholder: '请输入职业发展设想',
        span: 24
      },

      {
        label: '备注',
        id: 'remark',
        type: 'textarea',
        placeholder: '请输入备注',
        span: 24
      }
    ],
    // 教育情况
    [
      {
        label: '最高学历',
        id: 'highestDegree',
        type: 'select',
        required: true,
        placeholder: '请选择员工状态',
        span: 8
      },
      {
        label: '毕业院校 ',
        id: 'school',
        required: true,
        placeholder: '请输入毕业院校',
        span: 8
      },
      {
        label: '是否应届生',
        id: 'isTrainee',
        type: 'radio',
        required: true,
        placeholder: '请输入',
        span: 8
      },
      {
        label: '学       位',
        id: 'degreeOne',
        required: true,
        placeholder: '请输入学位',
        span: 8
      },
      {
        label: '专      业',
        id: 'professionOne',
        required: true,
        placeholder: '请输入专业',
        span: 8
      },
      {
        label: '毕业时间',
        id: 'graduationDateOne',
        placeholder: '毕业时间YYYY-MM-DD或 YYYY-MM',
        required: true,
        span: 8
      },

      {
        label: '第二学位',
        id: 'degreeTwo',
        placeholder: '请输入第二学位',
        span: 8
      },
      {
        label: '第二专业',
        id: 'professionTwo',
        placeholder: '请输入第二专业',
        span: 8
      },
      {
        label: '毕业时间',
        id: 'graduationDateTwo',
        placeholder: '毕业时间YYYY-MM-DD或 YYYY-MM',
        span: 8
      }
    ],
    // 设保信息 -- 公司缴纳基数及比例
    [
      [
        {
          label: '社保基数',
          id: 'socialBase',
          tip: true,
          tipContent: '请填写营业执照上完整的公司名称',
          placeholder: '请输入社保基数'
        },
        {
          label: '公积金基数 ',
          id: 'providentBase',
          placeholder: '请输入公积金基数'
        },
        {
          label: '企业年金 ',
          id: 'enterpriseBase',
          placeholder: '请输入企业年金'
        }
      ],
      [
        {
          label: '社保缴纳比例(%)',
          id: 'socialScale',
          placeholder: '请输入社保缴纳比例'
        },
        {
          label: '公积金缴纳比例(%)',
          id: 'providentScale',
          placeholder: '请输入公积金缴纳比例'
        },
        {
          label: '年金 比例(%)',
          id: 'enterpriseScale',
          placeholder: '请输入年金比例'
        }
      ],
      [
        { label: '医保基数', id: 'healthBase', placeholder: '请输入医保基数' },
        {
          label: '参保日期',
          id: 'insuredDate',
          placeholder: '参保日期YYYY-MM-DD或 YYYY-MM'
        }
      ]
    ]
  ],

  valueObject: {
    // employee基础信息
    employeeName: null,
    sex: null,
    birthday: null,
    nation: null,
    nativePlace: null,
    homeAddress: null,
    registeredType: null,
    residencePlace: null,
    currentAddress: null,
    idNumber: null,
    maritalStatus: null,
    workDate: null,
    political: null,
    establishment: null, //编制情况
    businessSector: null,
    entryPartyTime: null,
    technical: null,
    mobile: null,
    mail: null,
    wechat: null,
    postalCode: null,
    qq: null,
    hobbies: null,
    selfEvaluation: null,
    // employeeCompany入司情况
    companyId: null,
    deptId: null,
    position: null,
    employeeNo: null,
    job: null,
    entryMethod: null,
    entryCompanyTime: null,
    turnTime: null,
    employeeStatus: null,
    development: null,
    remark: null,
    // employeeEducation教育情况
    highestDegree: null,
    school: null,
    degreeOne: null,
    professionOne: null,
    graduationDateOne: null,
    degreeTwo: null,
    professionTwo: null,
    graduationDateTwo: null,
    isTrainee: null,
    // employeeSocial社保信息
    socialBase: null,
    providentBase: null,
    enterpriseBase: null,
    socialScale: null,
    providentScale: null,
    enterpriseScale: null,
    healthBase: null,
    speciality: null,
    officePhone: null,
    employeeNumber: null,
    leaveDate: null,
    insuredDate: null,
    jobCategory: null ///岗位类别
  },
  //标记新增/编辑
  tableFlag: '',
  // 学习经历
  employeeStudyList: [],

  // 工作经历
  employeeWorkList: [],

  // 家庭关系
  employeeFamilyList: [],

  // 奖惩信息
  employeeRewardList: [],

  // 合同信息
  employeeContractList: [],

  // 取得证书
  employeeCertificateList: [],

  // 附件资料
  employeeDocumentList: [],
  customerOption: {
    // 性别
    sex: [
      { label: '男', value: '1' },
      { label: '女', value: '2' }
    ],
    // 户口性质
    registeredType: [
      //   { label: '城镇', value: '1' },
      //   { label: '农村', value: '2' }
    ],
    // 婚姻状况
    maritalStatus: [
      { label: '已婚', value: '1' },
      { label: '未婚', value: '2' },
      { label: '其他', value: '3' }
    ],
    // 政治面貌
    political: [
      { label: '中共党员', value: '1' },
      { label: '团员', value: '2' },
      { label: '群众', value: '3' },
      { label: '民主党派', value: '4' }
    ],
    //编制情况
    establishment: [
      //   { label: '编制', value: '1' },
      //   { label: '非编制', value: '2' },
    ],
    // 员工状态
    employeeStatus: [],
    // 最高学历
    highestDegree: [
      //   { label: '硕士', value: '1' },
      //   { label: '本科', value: '2' },
      //   { label: '大专', value: '3' },
      //   { label: '中专', value: '4' },
      //   { label: '高中及以下', value: '5' }
    ],
    //所属单位列表
    companyId: [],
    // 所属部门列表
    deptId: [],
    // 岗位
    job: [],
    //入职方式
    entryMethod: [],
    // 职务
    position: [],
    businessSector: []
  },
  flag: false
})

const {
  contractObj,
  tableFlag,
  saveArr,
  showJgdiv,
  curIndex,
  tabRrr,
  activeNameT,
  cityResponse,
  // 学习经历 表格字段
  xxjlTableField,
  // 工作经历 表格字段
  gzjlTableField,
  // 家庭关系 表格字段
  jtgxTableField,
  // 奖惩信息 表格字段
  jcxxTableField,

  // 合同信息 表格字段
  htxxTableField,
  // 取得证书 表格字段
  qdzsTableField,
  // 培训情况 表格字段
  pxqkTableField,
  // 附件资料 表格字段
  wdzlTableField,
  // 头部标题
  headTitle,
  // 标题数组
  titleArr,
  activeName,
  // 字段数组
  fieldArr,

  valueObject,

  // 学习经历
  employeeStudyList,

  // 工作经历
  employeeWorkList,

  // 家庭关系
  employeeFamilyList,

  // 奖惩信息
  employeeRewardList,

  // 合同信息
  employeeContractList,

  // 取得证书
  employeeCertificateList,

  // 附件资料
  employeeDocumentList,

  customerOption,
  flag
} = toRefs(data)

const exceptTime = ref([
  'leaveDate',
  'retirementTime',
  'turnTimePlan',
  'internshipBeginTime',
  'internshipEndTime'
])

// 获取id对应label
function getLabel(id) {
  const array = [
    { label: '离职时间', id: 'leaveDate', value: '2' },
    { label: '预计转正时间', id: 'turnTimePlan', value: '3' },
    { label: '退休时间', id: 'retirementTime', value: '5' },
    { label: '实习开始时间', id: 'internshipBeginTime', value: '4' },
    { label: '实习结束时间', id: 'internshipEndTime', value: '4' }
  ]
  const result = array.find(v => v.id == id) || {}
  return result
}
// 监听deptId
// watch(valueObject.value.companyId, currDeptChange)
watch(
  () => valueObject.value.companyId,
  companyId => {
    currDeptChange(companyId)
  }
)

function changeEmployeeStatus(item, id) {
  console.log(item, id)
  valueObject.value.leaveDate = null
  if (id == 'employeeStatus' && item < 6) {
    isLeaveDate.value = true
  } else {
    isLeaveDate.value = false
  }
  // 清空时间
  valueObject.value.leaveDate = null
  valueObject.value.turnTimePlan = null
  valueObject.value.retirementTime = null
  valueObject.value.internshipBeginTime = null
  valueObject.value.internshipEndTime = null
}
//初始化
async function init() {
  //编制显示
  console.log('userStore===', userStore.permissions)
  const userPermissions = userStore.permissions
  if (userPermissions.length > 0) {
    userPermissions.map(item => {
      if (item == 'system:employee:check' || item == '*:*:*') {
        isEstablishment.value = '1'
      }
    })
    // 判断是否有查看vpn、职称职类分类权限
    if (
      !userPermissions.includes('system:employee:authority') &&
      !userPermissions.includes('*:*:*')
    ) {
      fieldArr.value[0] = fieldArr.value[0].filter(v => {
        if (!['classes', 'jobType', 'jobTitle', 'vpn'].includes(v.id)) {
          return v
        }
      })
    }
  }

  console.log('isEstablishment====', isEstablishment.value)
  // 籍贯
  cityResponse.value = await cityList({ type: '热门' })
  console.info('route', route)
  headTitle.value =
    route.currentRoute.value.query.flag == 'add'
      ? '员工档案新增'
      : '员工档案编辑'
  //标记新增/编辑
  tableFlag.value = route.currentRoute.value.query.flag
  // 所属单位列表
  let treeselectResponse = await treeselect({ deptType: 1 })
  customerOption.value.companyId = treeselectResponse.data

  // 岗位
  let jobResponse = await listJob()

  customerOption.value.classes = rsgl_classes.value
  customerOption.value.jobType = rgsl_job_type.value
  customerOption.value.jobTitle = rgsl_job_title.value
  customerOption.value.job = []
  jobResponse.data.forEach(item => {
    customerOption.value.job.push({
      label: item.postName,
      value: item.postName
    })
  })

  // 职务
  let positionResponse = toRaw(rsgl_ygda_position.value)
  customerOption.value.position = []
  positionResponse.forEach(item => {
    customerOption.value.position.push({ label: item.label, value: item.label })
  })

  // 入职方式
  let entrymethodResponse = toRaw(rsgl_ygda_entrymethod.value)
  customerOption.value.entryMethod = []
  entrymethodResponse.forEach(item => {
    customerOption.value.entryMethod.push({
      label: item.label,
      value: item.label
    })
  })
  //户口性质
  let registeredTypeResponse = toRaw(rsgl_ygda_registered.value)
  customerOption.value.registeredType = []
  registeredTypeResponse.forEach(item => {
    customerOption.value.registeredType.push({
      label: item.label,
      value: item.value
    })
  })
  //最高学历
  let highestDegreeResponse = toRaw(rsgl_ygda_highest_degree.value)
  customerOption.value.highestDegree = []
  highestDegreeResponse.forEach(item => {
    customerOption.value.highestDegree.push({
      label: item.label,
      value: item.value
    })
  })
  //编制情况
  let establishmentResponse = toRaw(rsgl_ygda_establishment.value)
  customerOption.value.establishment = []
  establishmentResponse.forEach(item => {
    customerOption.value.establishment.push({
      label: item.label,
      value: item.value
    })
  })
  //合同期限
  let contractResponse = toRaw(rsgl_ygda_contract.value)
  contractObj.value = []
  contractResponse.forEach(item => {
    contractObj.value.push({
      label: item.label,
      value: item.value
    })
  })
  //员工状态
  let employeeResponse = toRaw(rsgl_ygda_employee_status.value)
  customerOption.value.employeeStatus = []
  employeeResponse.forEach(item => {
    customerOption.value.employeeStatus.push({
      label: item.label,
      value: item.value
    })
  })
  //业务板块
  let businessResponse = toRaw(order_business_type.value)
  customerOption.value.businessSector = []
  customerOption.value.businessSector = proxy.handleTree(
    businessResponse,
    'value'
  )
  // businessResponse.forEach(item => {
  //   customerOption.value.businessSector.push({
  //     label: item.label,
  //     value: item.value
  //   })
  // })

  // 当前是员工档案编辑
  if (route.currentRoute.value.query.flag == 'update') {
    let response = await getInfo(route.currentRoute.value.query.employeeId)
    let data = response.data
    flag.value = true
    let employee = data.employee,
      employeeCompany = data.employeeCompany,
      employeeEducation = data.employeeEducation,
      employeeSocial = data.employeeSocial
    // employee.sex = employee.sex == '1' ? '男' : '女';
    // employee.registeredType = employee.registeredType == '1' ? '城镇' : '农村';
    // employee.maritalStatus = employee.maritalStatus == '1' ? '已婚' : '未婚';
    // employee.political = employee.political == '1' ? '中共党员' : employee.political == '2' ? '团员' : employee.political == '3' ? '群众' : '民主党派';
    // employeeCompany.employeeStatus = employeeCompany.employeeStatus == '1' ? '在职' : employeeCompany.employeeStatus == '2' ? '离职' : '试用期';
    // employeeEducation.highestDegree = employeeEducation.highestDegree == '1' ? '硕士' : employeeEducation.highestDegree == '2' ? '本科' : employeeEducation.highestDegree == '3' ? '大专' : employeeEducation.highestDegree == '4' ? '中专' : '高中及以下';

    employee.businessSector =
      employee.businessSector == null || employee.businessSector == ''
        ? ''
        : employee.businessSector.split(',')

    if (employeeCompany.employeeStatus < 6) {
      isLeaveDate.value = true
    }
    valueObject.value = {
      employeeCompanyId: employeeCompany.id,
      employeeEducationId: employeeEducation.id,
      employeeSocialId: employeeSocial == null ? null : employeeSocial.id,
      ...employee,
      ...employeeEducation,
      ...employeeSocial,
      ...employeeCompany
    }

    if (valueObject.value.jobTitle) {
      valueObject.value.jobTitle = valueObject.value.jobTitle.split(',')
    }

    // 学习经历
    await studyListGet()

    // 工作经历
    await workListGet()

    // 家庭关系
    await familyListGet()

    // 奖惩信息
    await rewardListGet()

    // 合同信息
    await contractListGet()

    // 取得证书
    await certificateListGet()
    // 附件资料
    await documentListGet()
  }
}

function hideDiv() {
  showJgdiv.value = false
  console.log('hideDiv')
}

function settingEvent(event) {
  console.log('settingEvent')
  event.stopPropagation() //此区域不受上面方法的影响
}

async function handleClick(val) {
  console.log(activeNameT.value)
  curIndex.value = -1
  cityResponse.value = await cityList({ type: val })
}

function handleItemClick(index, name) {
  curIndex.value = index
  valueObject.value.nativePlace = name
  showJgdiv.value = false
}

async function studyListGet() {
  // 学习经历
  let studyResponse = await studyList({
    employeeId: route.currentRoute.value.query.employeeId
  })
  // employeeStudyList.value = studyResponse.rows
  let array = studyResponse.rows
  if (array.length > 0) {
    const employeeStudyLists = []
    for (let i = 0; i < array.length; i++) {
      const num = array[i].fileName ? array[i].fileName.split(',').length : 0
      employeeStudyLists.push({
        ...array[i],
        fileNameNum: num
      })
    }
    employeeStudyList.value = employeeStudyLists
  } else {
    employeeStudyList.value = studyResponse.rows
  }
}

async function workListGet() {
  // 工作经历
  let workResponse = await workList({
    employeeId: route.currentRoute.value.query.employeeId
  })
  //   employeeWorkList.value = workResponse.rows
  let employeeWorkArray = workResponse.rows
  if (employeeWorkArray.length > 0) {
    const employeeWorkObj = []
    for (let i = 0; i < employeeWorkArray.length; i++) {
      const num = employeeWorkArray[i].fileName
        ? employeeWorkArray[i].fileName.split(',').length
        : 0
      employeeWorkObj.push({
        ...employeeWorkArray[i],
        fileNameNum: num
      })
    }
    employeeWorkList.value = employeeWorkObj
  } else {
    employeeWorkList.value = workResponse.rows
  }
}

async function familyListGet() {
  // 家庭关系
  let familyResponse = await familyList({
    employeeId: route.currentRoute.value.query.employeeId
  })
  employeeFamilyList.value = familyResponse.rows
}
async function rewardListGet() {
  // 奖惩信息
  let rewardResponse = await rewardList({
    employeeId: route.currentRoute.value.query.employeeId
  })
  employeeRewardList.value = rewardResponse.rows
}

async function contractListGet() {
  // 合同信息
  let contractResponse = await contractList({
    employeeId: route.currentRoute.value.query.employeeId
  })

  //   employeeContractList.value = contractResponse.rows
  let employeeContractArray = contractResponse.rows
  if (employeeContractArray.length > 0) {
    const employeeContractObj = []
    for (let i = 0; i < employeeContractArray.length; i++) {
      const num = employeeContractArray[i].fileName
        ? employeeContractArray[i].fileName.split(',').length
        : 0
      employeeContractArray[i].contractType = contractObj.value.find(
        item => item.value == employeeContractArray[i].contractType
      )
        ? contractObj.value.find(
            item => item.value == employeeContractArray[i].contractType
          ).label
        : ''
      employeeContractObj.push({
        ...employeeContractArray[i],
        fileNameNum: num
      })
    }
    employeeContractList.value = employeeContractObj
  } else {
    employeeContractList.value = contractResponse.rows
  }
}

async function certificateListGet() {
  // 取得证书
  let certificateResponse = await certificateList({
    employeeId: route.currentRoute.value.query.employeeId
  })
  //   employeeCertificateList.value = certificateResponse.rows
  let employeeCertificateArray = certificateResponse.rows
  if (employeeCertificateArray.length > 0) {
    const employeeCertificateObj = []
    for (let i = 0; i < employeeCertificateArray.length; i++) {
      const num = employeeCertificateArray[i].fileName
        ? employeeCertificateArray[i].fileName.split(',').length
        : 0
      employeeCertificateObj.push({
        ...employeeCertificateArray[i],
        fileNameNum: num
      })
    }
    employeeCertificateList.value = employeeCertificateObj
  } else {
    employeeCertificateList.value = certificateResponse.rows
  }
}

async function documentListGet() {
  // 附件资料
  let documentResponse = await getEmployeeFiles({
    employeeId: route.currentRoute.value.query.employeeId
  })
  employeeDocumentList.value = documentResponse.rows
}

function handleAdd(flag) {
  if (tableFlag.value == 'add') {
    handleAddOne(flag)
  } else {
    handleAddTwo(flag)
  }
}
function handleAddOne(flag) {
  switch (flag) {
    case '学习经历':
      employeeStudyList.value.push({
        startDate: null,
        endDate: null,
        school: null,
        profession: null,
        certificateNo: null,
        fileName: null,
        filePath: null,
        studyMethod: null,
        graduation: null,
        showFormDom: true
      })
      break
    case '工作经历':
      employeeWorkList.value.push({
        startDate: null,
        endDate: null,
        company: null,
        dept: null,
        position: null,
        certifier: null,
        tel: null,
        leaveReason: null,
        showFormDom: true
      })
      break
    case '家庭关系':
      employeeFamilyList.value.push({
        relation: null,
        name: null,
        birthday: null,
        political: null,
        company: null,
        position: null,
        tel: null,
        showFormDom: true
      })
      break
    case '奖惩信息':
      employeeRewardList.value.push({
        rewardDate: null,
        reward: null,
        rewardRemark: null,
        showFormDom: true
      })
      break
    case '合同信息':
      employeeContractList.value.push({
        contractNo: null,
        signDate: null,
        startDate: null,
        endDate: null,
        contractType: null,
        remark: null,
        fileName: null,
        filePath: null,
        showFormDom: true
      })
      break
    case '取得证书':
      employeeCertificateList.value.push({
        getDate: null,
        certificateName: null,
        certificateLevel: null,
        certificateAccess: null,
        certificateDept: null,
        certificateNo: null,
        fileName: null,
        filePath: null,
        showFormDom: true
      })
      break
    default:
      break
  }
}
function handleAddTwo(flag) {
  switch (flag) {
    case '学习经历':
      console.log('saveArr.value[0]', saveArr.value[0])
      if (saveArr.value[0] == 0) {
        saveArr.value[0] = 1
        employeeStudyList.value.push({
          startDate: null,
          endDate: null,
          school: null,
          profession: null,
          certificateNo: null,
          fileName: null,
          filePath: null,
          studyMethod: null,
          graduation: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '工作经历':
      if (saveArr.value[1] == 0) {
        saveArr.value[1] = 1
        employeeWorkList.value.push({
          startDate: null,
          endDate: null,
          company: null,
          dept: null,
          position: null,
          certifier: null,
          tel: null,
          leaveReason: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '家庭关系':
      if (saveArr.value[2] == 0) {
        saveArr.value[2] = 1
        employeeFamilyList.value.push({
          relation: null,
          name: null,
          birthday: null,
          political: null,
          company: null,
          position: null,
          tel: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '奖惩信息':
      if (saveArr.value[3] == 0) {
        saveArr.value[3] = 1
        employeeRewardList.value.push({
          rewardDate: null,
          reward: null,
          rewardRemark: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '合同信息':
      if (saveArr.value[4] == 0) {
        saveArr.value[4] = 1
        employeeContractList.value.push({
          contractNo: null,
          signDate: null,
          startDate: null,
          endDate: null,
          contractType: null,
          remark: null,
          fileName: null,
          filePath: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '取得证书':
      if (saveArr.value[5] == 0) {
        saveArr.value[5] = 1
        employeeCertificateList.value.push({
          getDate: null,
          certificateName: null,
          certificateLevel: null,
          certificateAccess: null,
          certificateDept: null,
          certificateNo: null,
          fileName: null,
          filePath: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break
    case '附件资料':
      if (saveArr.value[6] == 0) {
        saveArr.value[6] = 1
        employeeDocumentList.value.push({
          documentNo: null,
          documentNature: null,
          signDate: null,
          startDate: null,
          endDate: null,
          remark: null,
          fileName: null,
          filePath: null,
          showFormDom: true
        })
      } else
        proxy.$message({
          message: '请先保存当前数据',
          type: 'warning'
        })
      break

    default:
      break
  }
}
//tab切换
async function handleClickNext(tab, event) {
  if (tab.paneName == '8' && route.currentRoute.value.query.flag == 'update') {
    let sendData = { employeeId: route.currentRoute.value.query.employeeId }
    let documentResponse = await getEmployeeFiles(sendData)
    // 文档资料
    employeeDocumentList.value = documentResponse.rows
  }
}
//跳转
function handleLink(employeeId, id, tableName, index, item) {
  activeName.value = item
  let source = ''
  if (tableName == '学习经历') {
    source = 'tb_employee_study'
  } else if (tableName == '合同信息') {
    source = 'tb_employee_contract'
  } else if (tableName == '取得证书') {
    source = 'tb_employee_certificate'
  } else if (tableName == '工作经历') {
    source = 'tb_employee_work'
  }
  getEmployeeFiles({
    employeeId: employeeId,
    documentNature: source,
    documentNo: id
  }).then(res => {
    let documentResponse = res.rows
    employeeDocumentList.value = documentResponse
    // employeeDocumentList.value = res.data
    // window.location.href = res.config.url
  })
}
// 保存按钮
function handleSave(sendData, tableName, index) {
  sendData = {
    ...sendData,
    employeeId: route.currentRoute.value.query.employeeId
  }
  switch (tableName) {
    case '学习经历':
      // 数据校验
      if (sendData.startDate && !IsDate(sendData.startDate)) {
        proxy.$message({
          message: '请正确填写起始时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (sendData.endDate && !IsDate(sendData.endDate)) {
        proxy.$message({
          message: '请正确填写终止时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeStudyList.value[index].showFormDom = false
      saveArr.value[0] = 0
      break

    case '工作经历':
      // 数据校验
      if (sendData.startDate && !IsDate(sendData.startDate)) {
        proxy.$message({
          message: '请正确填写起始时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (sendData.endDate && !IsDate(sendData.endDate)) {
        proxy.$message({
          message: '请正确填写终止时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeWorkList.value[index].showFormDom = false
      saveArr.value[1] = 0
      break
    case '家庭关系':
      // 数据校验
      if (sendData.birthday && !IsDate(sendData.birthday)) {
        proxy.$message({
          message: '出生年月YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeFamilyList.value[index].showFormDom = false
      saveArr.value[2] = 0
      break
    case '奖惩信息':
      // 数据校验
      if (sendData.rewardDate && !IsDate(sendData.rewardDate)) {
        proxy.$message({
          message: '请正确填写时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeRewardList.value[index].showFormDom = false
      saveArr.value[3] = 0
      break
    case '合同信息':
      // 数据校验
      if (sendData.signDate && !IsDate(sendData.signDate)) {
        proxy.$message({
          message: '请正确填写签订日期YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (sendData.startDate && !IsDate(sendData.startDate)) {
        proxy.$message({
          message: '请正确填写起始时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (sendData.endDate && !IsDate(sendData.endDate)) {
        proxy.$message({
          message: '请正确填写终止时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeContractList.value[index].showFormDom = false
      saveArr.value[4] = 0
      break
    case '取得证书':
      // 数据校验
      if (sendData.getDate && !IsDate(sendData.getDate)) {
        proxy.$message({
          message: '请正确填写获取时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      employeeCertificateList.value[index].showFormDom = false
      saveArr.value[5] = 0
      break
    case '附件资料':
      // 数据校验
      employeeDocumentList.value[index].showFormDom = false
      saveArr.value[6] = 0
      break
    default:
      break
  }

  sendData.showFormDom = false
  if (route.currentRoute.value.query.flag == 'add') return
  if (!sendData.id) {
    switch (tableName) {
      case '学习经历':
        console.log('学习经历=====新增', sendData)
        addStudy(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          studyListGet()
        })
        break
      case '工作经历':
        addWork(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          workListGet()
        })
        break
      case '家庭关系':
        addFamily(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          familyListGet()
        })
        break
      case '奖惩信息':
        addReward(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          rewardListGet()
        })
        break
      case '合同信息':
        addContract(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          contractListGet()
        })
        break
      case '取得证书':
        addCertificate(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          certificateListGet()
        })
        break
      case '附件资料':
        addDocument(sendData).then(res => {
          proxy.$modal.msgSuccess('新增成功')
          documentListGet()
        })
        break
      default:
        break
    }
  } else {
    switch (tableName) {
      case '学习经历':
        updateStudy(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          studyListGet()
        })
        break
      case '工作经历':
        updateWork(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          workListGet()
        })
        break
      case '家庭关系':
        updateFamily(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          familyListGet()
        })
        break
      case '奖惩信息':
        updateReward(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          rewardListGet()
        })
        break
      case '合同信息':
        updateContract(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          contractListGet()
        })
        break
      case '取得证书':
        updateCertificate(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          certificateListGet()
        })
        break
      case '附件资料':
        updateDocument(sendData).then(res => {
          proxy.$modal.msgSuccess('修改成功')
          documentListGet()
        })
        break
      default:
        break
    }
  }
}

// 删除按钮
function handleRemove(id, tableName) {
  switch (tableName) {
    case '学习经历':
      delStudy(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        studyListGet()
      })
      break
    case '工作经历':
      delWork(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        workListGet()
      })
      break
    case '家庭关系':
      delFamily(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        familyListGet()
      })
      break
    case '奖惩信息':
      delReward(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        rewardListGet()
      })

      break
    case '合同信息':
      delContract(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        contractListGet()
      })

      break
    case '取得证书':
      delCertificate(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        certificateListGet()
      })
      break
    case '附件资料':
      delDocument(id).then(res => {
        proxy.$modal.msgSuccess('删除成功')
        documentListGet()
        studyListGet()
        workListGet()
        contractListGet()
        certificateListGet()
      })
      break
    default:
      break
  }
}
// 空白数组删除
function handleDel(tableName) {
  switch (tableName) {
    case '学习经历':
      saveArr.value[0] = 0
      break
    case '工作经历':
      saveArr.value[1] = 0
      break
    case '家庭关系':
      saveArr.value[2] = 0
      break
    case '奖惩信息':
      saveArr.value[3] = 0
      break
    case '合同信息':
      saveArr.value[4] = 0
      break
    case '取得证书':
      saveArr.value[5] = 0
      break
    case '附件资料':
      saveArr.value[6] = 0
      break
    default:
      break
  }
}

/** 转换部门数据结构 */
function normalizer(node) {
  if (node.children && !node.children.length) {
    delete node.children
  }
  return {}
}
async function currDeptChange(val) {
  let res = await treeselect({ deptId: val })
  customerOption.value.deptId = res.data
  if (flag.value) {
    flag.value = false
  } else {
    valueObject.value.deptId = null
  }
}
// 重置按钮
function reset() {
  useTagsViewStore().delView(router.currentRoute.value)
  router.go(-1)
}
function IsDate(str) {
  //如果是正确的日期格式返回true,否则返回false
  var regExp
  regExp = /\b\d{4}-\d{1,2}-\d{1,2}\b/
  //判断整体格式yyyy-mm-dd
  if (
    str == str.match(/\d{4}-\d{2}/gi) ||
    str == str.match(/\d{4}-\d{2}-\d{2}/gi)
  ) {
    var tmpArr
    tmpArr = str.split('-')
    var rYear, rMonth, rDay
    rYear = parseInt(tmpArr[0])
    rMonth = parseInt(tmpArr[1])
    rDay = parseInt(tmpArr[2]) ? parseInt(tmpArr[2]) : ''
    if (rMonth > 12) {
      return false
    } else {
      var rYearflag
      //判断润年
      if (rYear % 100 == 0 && rYear % 4 == 0) {
        rYearflag = true
      } else if (rYear % 4 == 0) {
        rYearflag = true
      } else {
        rYearflag = false
      }
      if (',1,3,5,7,8,10,12,'.indexOf(',' + rMonth + ',') != -1 && rDay < 32) {
        return true
      } else if (',4,6,9,11,'.indexOf(',' + rMonth + ',') != -1 && rDay < 31) {
        return true
      } else if (rDay < 29) {
        return true
      } else if (rYearflag && rDay < 30) {
        return true
      } else {
        return false
      }
    }
  } else {
    return false
  }
}

//暂存
function handleSubmit() {
  if (!valueObject.value.employeeName) {
    proxy.$message({
      message: '姓名不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.birthday) {
    proxy.$message({
      message: '出生年月不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.companyId) {
    proxy.$message({
      message: '所属单位不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.deptId) {
    proxy.$message({
      message: '所属部门不能为空！',
      type: 'warning'
    })
  } else {
    let sendData = {
      // employee基础信息
      employee: {
        employeeName: valueObject.value.employeeName,
        employeeId: null,
        sex: valueObject.value.sex,
        birthday: valueObject.value.birthday,
        nation: valueObject.value.nation,
        nativePlace: valueObject.value.nativePlace,
        homeAddress: valueObject.value.homeAddress,
        registeredType: valueObject.value.registeredType,
        residencePlace: valueObject.value.residencePlace,
        currentAddress: valueObject.value.currentAddress,
        idNumber: valueObject.value.idNumber,
        maritalStatus: valueObject.value.maritalStatus,
        workDate: valueObject.value.workDate,
        political: valueObject.value.political,
        establishment: valueObject.value.establishment,
        entryPartyTime: valueObject.value.entryPartyTime,
        technical: valueObject.value.technical,
        mobile: valueObject.value.mobile,
        mail: valueObject.value.mail,
        wechat: valueObject.value.wechat,
        postalCode: valueObject.value.postalCode,
        qq: valueObject.value.qq,
        hobbies: valueObject.value.hobbies,
        selfEvaluation: valueObject.value.selfEvaluation,
        businessSector: valueObject.value.businessSector
          ? valueObject.value.businessSector.toString()
          : '',
        speciality: valueObject.value.speciality, //新增特长
        officePhone: valueObject.value.officePhone, //新增办公电话
        vpn: valueObject.value.vpn,
        classes: valueObject.value.classes,
        jobType: valueObject.value.jobType,
        jobTitle: valueObject.value.jobTitle
          ? valueObject.value.jobTitle.toString()
          : null
      },
      // employeeCompany入司情况
      employeeCompany: {
        id: null,
        companyId: valueObject.value.companyId,
        deptId: valueObject.value.deptId,
        position: valueObject.value.position,
        employeeNo: valueObject.value.employeeNo,
        job: valueObject.value.job,
        entryMethod: valueObject.value.entryMethod,
        entryCompanyTime: valueObject.value.entryCompanyTime,
        turnTime: valueObject.value.turnTime,
        employeeStatus: valueObject.value.employeeStatus
          ? valueObject.value.employeeStatus
          : '6',
        development: valueObject.value.development,
        remark: valueObject.value.remark,
        employeeNumber: valueObject.value.employeeNumber, //新增员工编号
        leaveDate: valueObject.value.leaveDate, //新增离职时间
        jobCategory: valueObject.value.jobCategory //新增岗位类别
      },
      // employeeEducation教育情况
      employeeEducation: {
        id: null,
        highestDegree: valueObject.value.highestDegree,
        school: valueObject.value.school,
        degreeOne: valueObject.value.degreeOne,
        professionOne: valueObject.value.professionOne,
        graduationDateOne: valueObject.value.graduationDateOne,
        degreeTwo: valueObject.value.degreeTwo,
        professionTwo: valueObject.value.professionTwo,
        graduationDateTwo: valueObject.value.graduationDateTwo,
        isTrainee: valueObject.value.isTrainee
      },
      // employeeSocial社保信息
      employeeSocial: {
        id: null,
        socialBase: valueObject.value.socialBase,
        providentBase: valueObject.value.providentBase,
        enterpriseBase: valueObject.value.enterpriseBase,
        socialScale: valueObject.value.socialScale,
        providentScale: valueObject.value.providentScale,
        enterpriseScale: valueObject.value.enterpriseScale,
        healthBase: valueObject.value.healthBase,
        insuredDate: valueObject.value.insuredDate //参保日期
      },

      // employeeStudyList学习经历
      employeeStudyList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeStudyList.value
          : null,
      // employeeWorkList工作经历
      employeeWorkList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeWorkList.value
          : null,
      // employeeFamilyList家庭关系
      employeeFamilyList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeFamilyList.value
          : null,
      // employeeRewardList奖惩信息
      employeeRewardList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeRewardList.value
          : null,
      // employeeContractList合同信息
      employeeContractList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeContractList.value
          : null,
      // employeeCertificateList取得证书
      employeeCertificateList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeCertificateList.value
          : null,
      // 培训情况（暂略）
      // employeeDocumentList文档资料
      employeeDocumentList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeDocumentList.value
          : null
    }
    // 新增员工档案
    if (route.currentRoute.value.query.flag == 'add') {
      addEmployee(sendData).then(res => {
        proxy.$modal.msgSuccess('暂存成功！')
        useTagsViewStore().delView(router.currentRoute.value)
        router.go(-1)
      })
    }
  }
}

/** 提交按钮 */
function submitForm() {
  let regsIdNumber =
    /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
  let regsMobile = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/
  // 非下划线的单词字符 + 2个以上单词字符 + @ + 2位以上单词字符域名 + .2位以上小写字母做域名后缀 + (.2位以上二重域名后缀)?
  // var reg = /^(用户名)@(组织名)\.(一级域名后缀)(二级域名后缀)?$/
  let regsMail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ // /^([a-zA-Z\d][\w-]{2,})@(\w{2,})\.([a-z]{2,})(\.[a-z]{2,})?$/
  // 支持6-20个字母、数字，下划线或减号，以字母开头
  let regsWechat = /^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/
  let regsPostalCode = /^\d{6}$/
  // 要求必须是 5-15 位；
  // 0 不能开头；
  // 必须都是数字；
  let regsQQ = /^[1-9]{1}[0-9]{4,9}$/

  let regOfficePhone =
    /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/

  // 校验数据
  if (employeeStudyList.value.length != 0) {
    // '学习经历'
    for (var i = 0; i < employeeStudyList.value.length; i++) {
      if (
        employeeStudyList.value[i].startDate &&
        !IsDate(employeeStudyList.value[i].startDate)
      ) {
        proxy.$message({
          message: '请正确填写学习经历的起始时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (
        employeeStudyList.value[i].endDate &&
        !IsDate(employeeStudyList.value[i].endDate)
      ) {
        proxy.$message({
          message: '请正确填写学习经历的终止时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      // if (!employeeStudyList.value[i].school) {
      //   proxy.$message({
      //     message: '学习经历的毕业院校不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // i
      // if (!employeeStudyList.value[i].school) {
      //   proxy.$message({
      //     message: '学习经历的毕业院校不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeStudyList.value[i].profession) {
      //   proxy.$message({
      //     message: '学习经历的专业不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeStudyList.value[i].studyMethod) {
      //   proxy.$message({
      //     message: '学习经历的学习方式不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeStudyList.value[i].graduation) {
      //   proxy.$message({
      //     message: '学习经历的毕业情况不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
    }
  }

  if (employeeWorkList.value.length != 0) {
    // '工作经历'
    for (var j = 0; j < employeeWorkList.value.length; j++) {
      if (
        employeeWorkList.value[j].startDate &&
        !IsDate(employeeWorkList.value[j].startDate)
      ) {
        proxy.$message({
          message: '工作经历的起始时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      if (
        employeeWorkList.value[j].endDate &&
        !IsDate(employeeWorkList.value[j].endDate)
      ) {
        proxy.$message({
          message: '工作经历的终止时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      // if (!employeeWorkList.value[j].company) {
      //   proxy.$message({
      //     message: '工作经历的工作单位不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeWorkList.value[j].dept) {
      //   proxy.$message({
      //     message: '工作经历的部门不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeWorkList.value[j].position) {
      //   proxy.$message({
      //     message: '工作经历的担任职务不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeWorkList.value[j].leaveReason) {
      //   proxy.$message({
      //     message: '工作经历的离职原因不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
    }
  }

  if (employeeFamilyList.value.length != 0) {
    // '家庭关系'
    for (var k = 0; k < employeeFamilyList.value.length; k++) {
      if (
        employeeFamilyList.value[k].birthday &&
        !IsDate(employeeFamilyList.value[k].birthday)
      ) {
        proxy.$message({
          message: '家庭关系的出生年月YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      // if (!employeeFamilyList.value[k].relation) {
      //   proxy.$message({
      //     message: '家庭关系的关系不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeFamilyList.value[k].name) {
      //   proxy.$message({
      //     message: '家庭关系的姓名不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }

      // if (!employeeFamilyList.value[k].political) {
      //   proxy.$message({
      //     message: '家庭关系的政治面貌不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeFamilyList.value[k].company) {
      //   proxy.$message({
      //     message: '家庭关系的单位不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeFamilyList.value[k].position) {
      //   proxy.$message({
      //     message: '家庭关系的职务不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeFamilyList.value[k].tel) {
      //   proxy.$message({
      //     message: '家庭关系的联系电话不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
    }
  }
  if (employeeCertificateList.value.length != 0) {
    // '取得证书'
    for (var m = 0; m < employeeCertificateList.value.length; m++) {
      if (
        employeeCertificateList.value[m].getDate &&
        !IsDate(employeeCertificateList.value[m].getDate)
      ) {
        proxy.$message({
          message: '取得证书的获取时间YYYY-MM-DD或 YYYY-MM！',
          type: 'warning'
        })
        return false
      }
      // if (!employeeCertificateList.value[m].certificateName) {
      //   proxy.$message({
      //     message: '取得证书的证书名称不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeCertificateList.value[m].certificateNo) {
      //   proxy.$message({
      //     message: '取得证书的证书编号不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
      // if (!employeeCertificateList.value[m].fileName) {
      //   proxy.$message({
      //     message: '取得证书的证书附件不能为空！',
      //     type: 'warning'
      //   })
      //   return false
      // }
    }
  }

  if (!valueObject.value.employeeName) {
    proxy.$message({
      message: '姓名不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.sex) {
    proxy.$message({
      message: '性别不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.birthday) {
    proxy.$message({
      message: '出生年月不能为空！',
      type: 'warning'
    })
  } else if (
    valueObject.value.birthday &&
    !IsDate(valueObject.value.birthday)
  ) {
    proxy.$message({
      message: '请正确填写出生年月YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (!valueObject.value.nativePlace) {
    proxy.$message({
      message: '籍贯不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.homeAddress) {
    proxy.$message({
      message: '家庭地址不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.residencePlace) {
    proxy.$message({
      message: '户籍所在地不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.currentAddress) {
    proxy.$message({
      message: '现住地址不能为空！',
      type: 'warning'
    })
  } else if (
    valueObject.value.idNumber &&
    !regsIdNumber.test(valueObject.value.idNumber)
  ) {
    proxy.$message({
      message: '请输入正确的身份证号！',
      type: 'warning'
    })
  } else if (
    valueObject.value.mobile &&
    !regsMobile.test(valueObject.value.mobile)
  ) {
    proxy.$message({
      message: '请输入正确的手机号码！',
      type: 'warning'
    })
  } else if (valueObject.value.mail && !regsMail.test(valueObject.value.mail)) {
    proxy.$message({
      message: '请输入正确的个人邮箱！',
      type: 'warning'
    })
  } else if (
    valueObject.value.officePhone &&
    !regOfficePhone.test(valueObject.value.officePhone)
  ) {
    proxy.$message({
      message: '请输入正确的电话号码或者固话号码',
      type: 'warning'
    })
  }
  //    else if (
  //     valueObject.value.wechat &&
  //     !regsWechat.test(valueObject.value.wechat)
  //   ) {
  //     proxy.$message({
  //       message: '请输入正确的微信号码！',
  //       type: 'warning'
  //     })
  //   }
  else if (
    valueObject.value.postalCode &&
    !regsPostalCode.test(valueObject.value.postalCode)
  ) {
    proxy.$message({
      message: '请输入正确的邮政编码！',
      type: 'warning'
    })
  } else if (valueObject.value.qq && !regsQQ.test(valueObject.value.qq)) {
    proxy.$message({
      message: '请输入正确的QQ号码！',
      type: 'warning'
    })
  } else if (!valueObject.value.companyId) {
    proxy.$message({
      message: '所属单位不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.deptId) {
    proxy.$message({
      message: '所属部门不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.position) {
    proxy.$message({
      message: '职务不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.employeeNo) {
    proxy.$message({
      message: '员工工号不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.job) {
    proxy.$message({
      message: '岗位不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.entryMethod) {
    proxy.$message({
      message: '入职方式不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.employeeStatus) {
    proxy.$message({
      message: '员工状态不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.highestDegree) {
    proxy.$message({
      message: '最高学历不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.school) {
    proxy.$message({
      message: '毕业院校不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.isTrainee) {
    proxy.$message({
      message: '是否应届生不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.degreeOne) {
    proxy.$message({
      message: '学位不能为空！',
      type: 'warning'
    })
  } else if (!valueObject.value.professionOne) {
    proxy.$message({
      message: '专业不能为空！',
      type: 'warning'
    })
  } else if (
    !valueObject.value.graduationDateOne ||
    (valueObject.value.graduationDateOne &&
      !IsDate(valueObject.value.graduationDateOne))
  ) {
    proxy.$message({
      message: '请正确填写毕业时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.graduationDateTwo &&
    !IsDate(valueObject.value.graduationDateTwo)
  ) {
    proxy.$message({
      message: '请正确填写第二专业毕业时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.socialBase &&
    isNaN(valueObject.value.socialBase)
  ) {
    proxy.$message({
      message: '社保基数请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.providentBase &&
    isNaN(valueObject.value.providentBase)
  ) {
    proxy.$message({
      message: '公积金基数请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.enterpriseBase &&
    isNaN(valueObject.value.enterpriseBase)
  ) {
    proxy.$message({
      message: '企业年金请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.socialScale &&
    isNaN(valueObject.value.socialScale)
  ) {
    proxy.$message({
      message: '社保缴纳比例请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.providentScale &&
    isNaN(valueObject.value.providentScale)
  ) {
    proxy.$message({
      message: '公积金缴纳比例请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.enterpriseScale &&
    isNaN(valueObject.value.enterpriseScale)
  ) {
    proxy.$message({
      message: '年金比例请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.healthBase &&
    isNaN(valueObject.value.healthBase)
  ) {
    proxy.$message({
      message: '医保基数请输入数字！',
      type: 'warning'
    })
  } else if (
    valueObject.value.entryPartyTime &&
    !IsDate(valueObject.value.entryPartyTime)
  ) {
    proxy.$message({
      message: '请正确填写入党/入团时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.workDate &&
    !IsDate(valueObject.value.workDate)
  ) {
    proxy.$message({
      message: '请正确填写参加工作时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.insuredDate &&
    !IsDate(valueObject.value.insuredDate)
  ) {
    proxy.$message({
      message: '请正确填写参保日期YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.entryCompanyTime &&
    !IsDate(valueObject.value.entryCompanyTime)
  ) {
    proxy.$message({
      message: '请正确填写入司时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.turnTime &&
    !IsDate(valueObject.value.turnTime)
  ) {
    proxy.$message({
      message: '请正确填写转正时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else if (
    valueObject.value.leaveDate &&
    !IsDate(valueObject.value.leaveDate)
  ) {
    proxy.$message({
      message: '请正确填写离职时间YYYY-MM-DD或 YYYY-MM！',
      type: 'warning'
    })
  } else {
    let sendData = {
      // employee基础信息
      employee: {
        employeeName: valueObject.value.employeeName,
        employeeId:
          route.currentRoute.value.query.flag == 'update'
            ? valueObject.value.employeeId
            : null,
        sex: valueObject.value.sex,
        birthday: valueObject.value.birthday,
        nation: valueObject.value.nation,
        nativePlace: valueObject.value.nativePlace,
        homeAddress: valueObject.value.homeAddress,
        registeredType: valueObject.value.registeredType,
        residencePlace: valueObject.value.residencePlace,
        currentAddress: valueObject.value.currentAddress,
        idNumber: valueObject.value.idNumber,
        maritalStatus: valueObject.value.maritalStatus,
        workDate: valueObject.value.workDate,
        political: valueObject.value.political,
        establishment: valueObject.value.establishment,
        entryPartyTime: valueObject.value.entryPartyTime,
        technical: valueObject.value.technical,
        mobile: valueObject.value.mobile,
        mail: valueObject.value.mail,
        wechat: valueObject.value.wechat,
        postalCode: valueObject.value.postalCode,
        qq: valueObject.value.qq,
        hobbies: valueObject.value.hobbies,
        selfEvaluation: valueObject.value.selfEvaluation,
        businessSector: valueObject.value.businessSector
          ? valueObject.value.businessSector.toString()
          : '',
        speciality: valueObject.value.speciality, //新增特长
        officePhone: valueObject.value.officePhone, //新增办公电话
        vpn: valueObject.value.vpn,
        classes: valueObject.value.classes,
        jobType: valueObject.value.jobType,
        jobTitle: valueObject.value.jobTitle
          ? valueObject.value.jobTitle.toString()
          : null
      },
      // employeeCompany入司情况
      employeeCompany: {
        id:
          route.currentRoute.value.query.flag == 'update'
            ? valueObject.value.employeeCompanyId
            : null,
        companyId: valueObject.value.companyId,
        deptId: valueObject.value.deptId,
        position: valueObject.value.position,
        employeeNo: valueObject.value.employeeNo,
        job: valueObject.value.job,
        entryMethod: valueObject.value.entryMethod,
        entryCompanyTime: valueObject.value.entryCompanyTime,
        turnTime: valueObject.value.turnTime,
        employeeStatus: valueObject.value.employeeStatus,
        development: valueObject.value.development,
        remark: valueObject.value.remark,
        employeeNumber: valueObject.value.employeeNumber, //新增员工编号
        leaveDate: valueObject.value.leaveDate, //新增离职时间
        jobCategory: valueObject.value.jobCategory //新增岗位类别
      },
      // employeeEducation教育情况
      employeeEducation: {
        id:
          route.currentRoute.value.query.flag == 'update'
            ? valueObject.value.employeeEducationId
            : null,
        highestDegree: valueObject.value.highestDegree,
        school: valueObject.value.school,
        degreeOne: valueObject.value.degreeOne,
        professionOne: valueObject.value.professionOne,
        graduationDateOne: valueObject.value.graduationDateOne,
        degreeTwo: valueObject.value.degreeTwo,
        professionTwo: valueObject.value.professionTwo,
        graduationDateTwo: valueObject.value.graduationDateTwo,
        isTrainee: valueObject.value.isTrainee
      },
      // employeeSocial社保信息
      employeeSocial: {
        id:
          route.currentRoute.value.query.flag == 'update'
            ? valueObject.value.employeeSocialId
            : null,
        socialBase: valueObject.value.socialBase,
        providentBase: valueObject.value.providentBase,
        enterpriseBase: valueObject.value.enterpriseBase,
        socialScale: valueObject.value.socialScale,
        providentScale: valueObject.value.providentScale,
        enterpriseScale: valueObject.value.enterpriseScale,
        healthBase: valueObject.value.healthBase,
        insuredDate: valueObject.value.insuredDate //参保日期
      },

      // employeeStudyList学习经历
      employeeStudyList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeStudyList.value
          : null,
      // employeeWorkList工作经历
      employeeWorkList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeWorkList.value
          : null,
      // employeeFamilyList家庭关系
      employeeFamilyList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeFamilyList.value
          : null,
      // employeeRewardList奖惩信息
      employeeRewardList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeRewardList.value
          : null,
      // employeeContractList合同信息
      employeeContractList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeContractList.value
          : null,
      // employeeCertificateList取得证书
      employeeCertificateList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeCertificateList.value
          : null,
      // 培训情况（暂略）
      // employeeDocumentList文档资料
      employeeDocumentList:
        route.currentRoute.value.query.flag == 'add'
          ? employeeDocumentList.value
          : null
    }

    // 新增员工档案
    if (route.currentRoute.value.query.flag == 'add') {
      addEmployee(sendData).then(res => {
        proxy.$modal.msgSuccess('新增成功')
        useTagsViewStore().delView(router.currentRoute.value)
        router.go(-1)
      })
    }
    // 修改员工档案
    else {
      updateEmployee(sendData).then(res => {
        proxy.$modal.msgSuccess('修改成功')
        useTagsViewStore().delView(router.currentRoute.value)
        router.go(-1)
      })
    }
  }
}

init()
</script>
<style scoped lang="scss">
.page {
  padding: 20px 60px;
}

.el-collapse {
  margin-bottom: 40px;
}

.header {
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 20px;
}

.collapse-title {
  font-weight: 600;
  font-size: 15px;
}

.block {
  width: 5px;
  display: inline-block;
  height: 16px;
  background-color: rgb(62, 146, 255);
  margin-right: 8px;
  margin-left: -14px;
}

.content {
  margin-bottom: 100px;
}

.title {
  display: flex;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 10px;
}

.collapse .row:last-child {
  margin-bottom: 10px;
}

.item-label,
.item-value {
  text-align: center;
  font-size: 12px;
  line-height: 30px;
}

.item-label {
  text-align: left;
}

.footer {
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  border-top: 1px solid lightgray;
  z-index: 99999;

  .el-button {
    width: 100px;
  }
}

::v-deep .el-tabs__item {
  padding: 0 10px;
}

.jgdiv {
  border: solid 1px #dfe4ed;
  padding: 10px 20px;
  box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  position: absolute;
  border-radius: 4px;
  z-index: 9999;
  margin-left: 0px;
  margin-top: 10px;
  width: 450px;
  background-color: #fff;

  .tab-pane {
    display: flex;
    // align-items: center;
    flex-wrap: wrap;
    max-height: 274px;
    overflow-y: scroll;

    .city-item-div {
      margin-bottom: 10px;
      border-radius: 4px;
      width: 70px;
      // height: 30px;
      line-height: 20px;
      padding: 5px 10px;

      display: flex;
      // align-items: center;
      padding-left: 10px;
      cursor: pointer;
    }

    .active {
      background-color: #409eff;
      color: #fff;
    }
  }
}
</style>
